﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using BLL;
using MOD;

namespace MapServer.Adhs
{
    public partial class GetadsList1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String sReturnValue = String.Empty;
            if ( Request["userId"] != null)
            {
                sReturnValue = GetAdsList(Convert.ToInt64(Request["userId"]));
            }
            Response.Write(sReturnValue);
        }
        private String GetAdsList(Int64 iUserId)
        {
            B_AdInfo bAo = new B_AdInfo();
            String sValue = "998";
            try
            {
                DataTable dDt = new DataTable();
                int iCount = 10;
                int i = 0;
                dDt = bAo.Select(iUserId,iCount);
                if (dDt.Rows.Count != 0)
                {
                    String[] sArrayList = new String[dDt.Rows.Count];
                    for (i = 0; i < dDt.Rows.Count; i++)
                    {
                        sArrayList[i] = "{\"id\":" + dDt.Rows[i]["id"].ToString() + ",\"weiboId\":" + dDt.Rows[i]["weiboId"].ToString() + ",\"userId\":" + dDt.Rows[i]["userId"].ToString() + ",\"createTime\":" + "\"" + dDt.Rows[i]["createTime"].ToString() + "\"}";
                    }
                    sValue = "001";
                    sValue = JsonParameters.CreateJsonParameters(String.Empty, sValue, sArrayList);
                }
                else
                {
                    sValue = "012";
                    sValue = JsonParameters.CreateJsonParameters(String.Empty, sValue);
                }
            }
            catch
            {
                sValue = JsonParameters.CreateJsonParameters(String.Empty, sValue);
            }

            return sValue;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
